home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 5 / Gold Medal Software - Volume 5 (Gold Medal) (1995).iso / windows / misc / tapecalc.arj / ABOUTBOX.BAS next >
BASIC Source File  |  1994-10-20  |  6KB  |  148 lines

  1. Option Explicit
  2. ' Any program that includes this file must also include ABOUTBOX.TXT.
  3.  
  4. ' This re-usable component was originally created by Neil
  5. ' J. Rubenking for the PC Magazine utility INIBAK.
  6.  
  7. ' The AB_NO_xxxx constants are used to exclude informational lines
  8. ' from the About Box display.  You pass one or more of them, combined
  9. ' using OR, as the last parameter to DisplayAboutBox.
  10. Global Const AB_NO_USER = &H1
  11. Global Const AB_NO_COMPANY = &H2
  12. Global Const AB_NO_WINVER = &H4
  13. Global Const AB_NO_DOSVER = &H8
  14. Global Const AB_NO_WINMODE = &H10
  15. Global Const AB_NO_MEMORY = &H20
  16. Global Const AB_NO_80x87 = &H40
  17. Global Const AB_NO_FSR = &H80
  18.  
  19. Global Excl% ' Global variable holds bit flags for excluded items.
  20.  
  21.  
  22. ' GetSystemMetrics returns the size (in pixels) of various on-screen
  23. ' items.  There are many more SM_xxxx constants besides those defined
  24. ' below.  The About Box uses the sizes to set its position on screen.
  25. Declare Function GetSystemMetrics% Lib "User" (ByVal nIndex%)
  26. Global Const SM_CYCAPTION = &H4
  27. Global Const SM_CYMENU = &HF
  28. Global Const SM_CXSIZE = &H1F
  29.  
  30. ' API functions used in getting user and company name
  31. Declare Function LoadLibrary% Lib "Kernel" (ByVal LibFileName$)
  32. Declare Sub FreeLibrary Lib "Kernel" (ByVal hInst%)
  33. Declare Function LoadString% Lib "User" (ByVal hInst%, ByVal idResource%, ByVal Buffer$, ByVal cBuffer%)
  34.  
  35. ' GetVersion returns both Windows and DOS versions
  36. Declare Function GetVersion& Lib "Kernel" ()
  37.  
  38. ' GetWinFlags returns a Long that's filled with bit-flags providing
  39. ' information about Windows.  We use only 3 of its 13 flags
  40. Declare Function GetWinFlags& Lib "Kernel" ()
  41. Global Const WF_PMODE = &H1
  42. Global Const WF_ENHANCED = &H20
  43. Global Const WF_80x87 = &H400
  44.  
  45. ' GetFreeSpace returns the amount of free memory
  46. Declare Function GetFreeSpace& Lib "Kernel" (ByVal wFlags%)
  47.  
  48. ' Free System Resources are a special kind of memory that can run out
  49. ' before your main memory runs out.
  50. Declare Function GetFreeSystemResources% Lib "User" (ByVal fuSysResource%)
  51. Global Const GFSR_SYSTEMRESOURCES = 0
  52. Global Const GFSR_GDIRESOURCES = 1
  53. Global Const GFSR_USERRESOURCES = 2
  54.  
  55. Sub DisplayAboutBox (F As Form, ByVal ProgName$, ByVal Version, ByVal CoprDate, ByVal CoprName$, ByVal Ex1$, ByVal Ex2$, ByVal Exclude%, ByVal Center%, ByVal Fore&, ByVal Back&)
  56. 'Your program simply calls this function to display an about box.
  57. 'F         - the main form of the calling program, used to get an
  58. '            icon for display and to position the about box.
  59. 'ProgName  - program name, for caption and first line
  60. 'Version   - version number, displayed as 0.00
  61. 'CoprDate  - copyright year
  62. 'CoprName  - copyright holder's name
  63. 'Ex1       - extra data line 1 (optional)
  64. 'Ex2       - extra data line 2 (optional)
  65. 'Exclude   - used to exclude info from the about box.  AB_NO_xxxx
  66. '            constants are bit-flags for this parameter.  e.g. to
  67. '            exclude displaying DOS & Windows versions, pass
  68. '            AB_NO_DOSVER OR AB_NO_WINVER
  69. 'Center    - if TRUE, About box is centered on screen; if FALSE, About
  70. '            box is displayed offset from calling window.
  71. 'Fore,Back - foreground and background colors for box; 0 to use default
  72.   Const MODAL = 1
  73.   Excl = Exclude
  74.   Load FAB
  75.   Dim N%
  76.   If Fore Then
  77.     FAB.ForeColor = Fore
  78.     FAB.CoprLabel.ForeColor = Fore
  79.     FAB.NameLabel.ForeColor = Fore
  80.     For N = 0 To 14
  81.       FAB.OptLabel(N).ForeColor = Fore
  82.     Next N
  83.     FAB.Shape1.BorderColor = Fore
  84.   End If
  85.   If Back Then
  86.     FAB.BackColor = Back
  87.     FAB.CommandOK.BackColor = Back
  88.     FAB.CoprLabel.BackColor = Back
  89.     FAB.IconPicture.BackColor = Back
  90.     FAB.NameLabel.BackColor = Back
  91.     FAB.Shape1.FillColor = Back
  92.     For N = 0 To 14
  93.       FAB.OptLabel(N).BackColor = Back
  94.     Next N
  95.   End If
  96.   If Center Then
  97.     FAB.Left = (Screen.Width - FAB.Width) \ 2
  98.     FAB.Top = (Screen.Height - FAB.Height) \ 2
  99.   Else
  100.     ' Place the About box over the calling window, offset downward
  101.     ' and to the right
  102.     Dim Tmp% ' variable to keep lines of code from becoming TOO long
  103.     Tmp = GetSystemMetrics(SM_CXSIZE)
  104.     FAB.Left = F.Left + Tmp * Screen.TwipsPerPixelX
  105.     Tmp = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYMENU)
  106.     FAB.Top = F.Top + Tmp * Screen.TwipsPerPixelY
  107.     ' If about box now extends off the screen, move it back ON
  108.     If FAB.Left + FAB.Width > Screen.Width Then
  109.       FAB.Left = Screen.Width - (FAB.Width + 30)
  110.     End If
  111.     If FAB.Top + FAB.Height > Screen.Height Then
  112.       FAB.Top = Screen.Height - (FAB.Height + 30)
  113.     End If
  114.   End If
  115.   FAB.IconPicture.Picture = F.Icon
  116.   FAB.Caption = "About " + ProgName$
  117.   Dim Temp$ ' variable to keep lines of code from becoming TOO long
  118.   Temp = ProgName$ + ", Version " + Format$(Version, "0.00")
  119.   FAB.NameLabel.Caption = Temp
  120.   Temp = "Copyright ⌐ " + CoprDate + " by " + CoprName
  121.   FAB.CoprLabel.Caption = Temp
  122.   If Ex1 = "" Then
  123.     EliminateLabel 0
  124.   Else
  125.     FAB.OptLabel(0).Caption = Ex1
  126.   End If
  127.   If Ex2 = "" Then
  128.     EliminateLabel 1
  129.   Else
  130.     FAB.OptLabel(1).Caption = Ex2
  131.   End If
  132.   FAB.Show MODAL
  133. End Sub
  134.  
  135. Sub EliminateLabel (ByVal Which%)
  136.   ' If one of the informational labels in the about box is not wanted,
  137.   ' make it invisible and move all the other labels up to fill in the
  138.   ' space.  Then shrink the form as well.
  139.   FAB.OptLabel(Which).Visible = False
  140.   Dim N%, H%
  141.   H = FAB.OptLabel(0).Height
  142.   For N = Which + 1 To 14
  143.     FAB.OptLabel(N).Top = FAB.OptLabel(N).Top - H
  144.   Next N
  145.   FAB.Height = FAB.Height - H
  146. End Sub
  147.  
  148.